$(function(){
  $('.btn').on('click',function(e){
    e.preventDefault()
  const email=$('#email').val()
  const pwd=$('#password').val()
  const parse={
    email,
    password:pwd,
  }
  if(email&&!email.trim()){
    alert('请输入用户名')
    return
  }
  if(pwd&&!pwd.trim()){
    alert('请输入密码')
    return
  }

  $.ajax('http://192.168.2.100:3001/login',{
    type:'post',
    data:parse,
    success:function(res){
      // console.log(res);
      // console.log(res.token);
      const token=res.token
      if(token){
        localStorage.setItem('token',token)
        location.href='/admin/index.html'
      }else{
        alert('登陆失败')
      }
    },
    error:function(msg){
      console.log('获取失败');
    }
  })
})
})